<?php
/**
 * 用户算力矿机订单
 */
namespace app\admin\model;
use app\common\model\MemberArithmeticalPower as MemberArithmeticalPowerModel;

class MemberArithmeticalPower extends MemberArithmeticalPowerModel
{
    /**
     * 算力矿机管理
     * @param $pid  矿机ID
     * @param int $page 页码
     * @param int $limit    每页数量
     * @param array $where  条件
     * @param string $order 排序
     * @return array
     * @throws \think\db\exception\DbException
     */
    public static function getList($page=1,$limit=20,$where=[],$order = 'id desc'){
        $data = self::where($where)->order($order)->paginate(['list_rows'=>$limit,'page'=>$page])->toArray();
        return $data;
    }

    /**
     * 统计矿机订单数量
     * @param $where 查询条件
     * @param int $pay_statue   支付状态 0:所有 1:支付成功 2:待支付
     * @return int
     */
    public static function count_order($where,$pay_statue = 0){
        if($pay_statue != 0){
            $where[] = ['pay_status','=',$pay_statue];
        }
        return self::where($where)->count();
    }
}